package logic

import (
	"context"
	"rent-ease/model"

	"rent-ease/rentrpc/internal/svc"
	"rent-ease/rentrpc/rentrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowLogic) Show(in *rentrpc.ShowRequest) (*rentrpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	var rent model.Rent
	model.DB.Where("id=?", in.RentId).Find(&rent)
	return &rentrpc.ShowResponse{
		RentName: rent.RentName,
		Price:    float32(rent.Price),
		Address:  rent.Address,
		RentId:   int64(rent.ID),
	}, nil
}
